54A - Presents - CodeForces Solution


implementation *1300

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;

int arr[800];
int main()
{
    memset(arr,0,sizeof(arr));
   int n,k,c,d;
   cin>>n>>k>>c;
   for(int i=0;i<c;++i){
       cin>>d;
       arr[d]++;
   }
   int counter=0,ans=0;

   for(int i=1;i<=n;++i){
       if(arr[i]!=0){
           counter=0;
           ans++;
       }
       else{
           counter++;
           if(counter==k)
           {
               counter=0;
               ans++;
           }
       }
   }
   cout<<ans;


    return 0;
}


Comments

Submit
0 Comments
More Questions

255A - Greg's Workout
1059A - Cashier
1389C - Good String
1561A - Simply Strange Sort
1337B - Kana and Dragon Quest game
137C - History
1443C - The Delivery Dilemma
6C - Alice Bob and Chocolate
1077C - Good Array
285B - Find Marble
6A - Triangle
1729A - Two Elevators
1729B - Decode String
1729C - Jumping on Tiles
1729E - Guess the Cycle Size
553B - Kyoya and Permutation
1729D - Friends and the Restaurant
1606C - Banknotes
580C - Kefa and Park
342A - Xenia and Divisors
1033A - King Escape
39D - Cubical Planet
1453A - Cancel the Trains
645A - Amity Assessment
1144A - Diverse Strings
1553B - Reverse String
1073A - Diverse Substring
630N - Forecast
312B - Archer
34D - Road Map